package com.distortiongames.escalol
{
	import com.distortiongames.escalol.scene.SceneGame;
	import com.greensock.OverwriteManager;
	import com.pblabs.core.PBGroup;
	import com.pblabs.debug.Console;
	import com.pblabs.debug.ConsoleCommandManager;
	import com.pblabs.input.KeyboardManager;
	import com.pblabs.property.PropertyManager;
	import com.pblabs.time.TimeManager;
	import flash.display.*;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.*;
	import flash.events.Event;
	
	/**
	 * ...
	 * @author Jefferson Wagner
	 */
	[SWF(width="800", height="600", frameRate="60",wmode="gpu", backgroundColor="#000000")]
	public class Main extends Sprite 
	{	
		public var rootGroup:PBGroup = new PBGroup();
		
		public function Main():void 
		{
			if (stage) init();
			
			else addEventListener(Event.ADDED_TO_STAGE, init);
			
			OverwriteManager.init(OverwriteManager.NONE);
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
			
            rootGroup.initialize();
            rootGroup.name = "EscalolSceneGroup";
			rootGroup.registerManager(Stage, stage);
            rootGroup.registerManager(PropertyManager, new PropertyManager());
            rootGroup.registerManager(ConsoleCommandManager, new ConsoleCommandManager());
            rootGroup.registerManager(TimeManager, new TimeManager());
            rootGroup.registerManager(KeyboardManager, new KeyboardManager());
            rootGroup.registerManager(Console, new Console());
			
			var scene:SceneGame = new SceneGame();
			scene.owningGroup = rootGroup;
			scene.initialize();
			
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
		}
	}
}